print("Appending a child test1");
var x = rt.createObject("test1");
rt.appendChild(x);
print("Tree = \n" + rt.objectTree());

print("Insert a child test2 in front of test1");
x = rt.createObject("test2");
rt.insertBefore(x,rt.test1);
print("Tree = \n" + rt.objectTree());

print("Insert test3 as child of test2");
x = rt.createObject("test3");
rt.test2.appendChild(x);
print("Tree = \n" + rt.objectTree());

print("Insert test3 as child of test1");
x = rt.createObject("test3");
rt.test1.appendChild(x);
print("Tree = \n" + rt.objectTree());

print("Clone test2 and put it as child to test 1");
x = rt.test2.clone();
rt.test1.appendChild(x);
print("Tree = \n" + rt.objectTree());

print("The children of rt")
print(rt.children());

print("The children of rt.test1")
x = rt.test1;
print(x.children());

print("Remove test 1");
x = rt.test1;
x = rt.removeChild(x);
print("Tree = \n" + rt.objectTree());

print("Replace test2 with test1");
x = rt.replaceChild(x,rt.test2);
print("Tree = \n" + rt.objectTree());




